When I start developing a new app that uses the Ext library, I first just include everything because it allows for rapid development in the initial stages. I never have to worry about if I’m including the right features. However, as the app matures – queries are added, UI is strengthened, configuration is complexified (yes, I said it) – the pages start to bog down from the massive 500k include.
Splitting the Ext features into individual files allows for two things:
Here’s an example of my Ext libraries for a particularly heavy page:
<script type="text/javascript" src="js/ext-core.js"></script>
<script type="text/javascript" src="js/ext-buttons.js"></script>
<script type="text/javascript" src="js/ext-data.js"></script>
<script type="text/javascript" src="js/ext-dialogs.js"></script>
<script type="text/javascript" src="js/ext-form.js"></script>
<script type="text/javascript" src="js/ext-form-combo.js"></script>
<script type="text/javascript" src="js/ext-layout.js"></script>
<script type="text/javascript" src="js/ext-quicktips.js"></script>
<script type="text/javascript" src="js/Ext.ux.InfoPanel.js"></script>
<script type="text/javascript" src="js/Ext.ux.Accordion.js"></script>
This is stripped from the most feature-rich Ext page I’ve developed to date, and by splitting things out, the JS is down to 380k from 550k. Still large, but significantly smaller than just including everything.
This is easily done by using the Build Your Own Ext page. When you want to add a specific piece of functionality, simply use that page to download it, strip out the core code so you’re left with only the objects you need, and include it in your page.
5 Responses for "Splitting Sencha ExtJS is good food"
Steve -
Were the js files already part of their package or did you create those files?
I created each one from the Build Your Own Ext page. All I did was download logical packages and then used a diff tool strip out the core objects from each one so I was left with just the ones needed for that particular functionality.
If you include the ext-all package the script caches in your browser… I suppose there is a case for breaking it out, but then you have to do that for every page that you need a feature on.
Wouldn’t it just make more sense to include all? it’s not a big file really.
@Chris: While it is true that the 500k file will cache there are some things to consider.
The user may have caching disabled.
It will not be cached for eternity.
Some apps cannot allow caching for various business reasons so the files are reloaded on every request.
Given all this, I find it smarter simply to make the files as small as possible. It’s not hard, it’s better for the users, and it’s just plain smart in the long run.
This is a really good idea. Any chance I could download these from you? I could use them in the cf ext stuff I am doing and it would save me a lot of downloading and diff work!
Leave a reply